package com.zhentao.day02.am;

import java.util.Objects;

public class Piao {
  String cheCi;
  String zhanTai ;
  String zuoWei;

  public Piao(String cheCi, String zhanTai, String zuoWei) {
    this.cheCi = cheCi;
    this.zhanTai = zhanTai;
    this.zuoWei = zuoWei;
  }

  @Override
  public String toString() {
    return "\t chuChe: " + cheCi + " \t zhanTai: "
        + zhanTai + " \t zuoWei: " + zuoWei;
  }

  @Override
  public int hashCode() {
    if (this == null) {
      return 0;
    }
    int res = 17 ;
    res = 31 * res + Objects.hashCode(cheCi);
    res = 31 * res + Objects.hashCode(zhanTai);
    res = 31 * res + Objects.hashCode(zuoWei);
    return res;
  }

  @Override
  public boolean equals(Object obj) {
    // 此时比较的是两个对象的地址
    if (this == obj ){  return true ;}
    if (obj == null | this.getClass() !=  obj.getClass()){return false ; }
    Piao piao = (Piao) obj;
    // 比较两个字符串是否相同
    return Objects.equals(this.cheCi,piao.cheCi)&&Objects.equals(this.zhanTai,piao.zhanTai)&&
        Objects.equals(this.zuoWei,piao.zuoWei);
  }
}
